{% extends 'VipBundle:Vip:layout.html.twig' %}

{% block title %}会员专区 - {{ parent() }}{% endblock %}

{% set menu = 'index' %}

{% block main_body %}

    <div class="col-md-9">

      {% set blocks = data('Blocks',{'codes':['vip_banner'] }) %}
      {% if blocks.vip_banner %}
        <div class="homepage-feature homepage-feature-slides mbl">
          <div class="cycle-pager"></div>
          {{ blocks.vip_banner|raw }}
        </div>
      {% endif %}

      <div class="es-box-heading"><h2>购买会员</h2></div>
      <ul class="course-wide-list">
        {% for level in levels %}
          {% if userVip %}
            {% set currentLevel = levels[userVip.levelId] %}
          {% endif %}
          {% if level.seq >= currentLevel.seq|default(0) %}
            <li class="course-item clearfix member-item">
              <a href="{{ path('vip_course_explore', {levelId:level.id}) }}"><img class="course-picture" src="{{ level.picture|default(asset('assets/img/default/vip-default.png')) }}" alt="{{ level.name }}"></a>
              <div class="course-view">
                <a href="{{ path('vip_course_explore', {levelId:level.id}) }}" class="btn btn-link">查看会员课程</a>

                {% if userVip|default(null) == null %}
                  <a  href="{{ path('vip_buy', {level:level.id}) }}" class="btn btn-primary">购买</a>
                {% elseif level.id == userVip.levelId|default(null) %}
                  <a  href="{{ path('vip_buy', {level:level.id}) }}" class="btn btn-primary">续费</a>
                {% else %}
                  <a  href="{{ path('vip_upgrade') }}" class="btn btn-primary">升级</a>
                {% endif %}
              </div>
              <div class="course-body">
                <h4 class="course-title"><a href="{{ path('vip_course_explore', {levelId:level.id}) }}">{{ level.name}}</a></h4>
                <div class="course-about ellipsis">{{ level.description|raw }}</div>
                <div class="course-footer clearfix">
                  <span class="course-price" >{{ level.monthPrice }}元/月 {{ level.yearPrice }}元/年</span>
                </div>
              </div>
            </li>
          {% endif %}
        {% endfor %}
      </ul>

      <div class="es-box-heading">
        <a href="{{ path('vip_course_explore', { sort:'latest'} ) }}" class="pull-right">更多 &raquo;</a>
        <h2>最新会员课程</h2>
      </div>
      <div class="es-box-body">
        {% if latestCourses %}
          {{ render(controller('TopxiaWebBundle:Course:coursesBlock', {courses:latestCourses, view: 'grid'})) }}
        {% else %}
          <div class="empty">还没有发布的课程</div>
        {% endif %}
      </div>

      <div class="es-box-heading">
        <a href="{{ path('vip_course_explore', { sort:'popular'} ) }}" class="pull-right">更多 &raquo;</a>
        <h2>最新热门课程</h2>
      </div>
      <div class="es-box-body">
        {% if hotestCourses %}
          {{ render(controller('TopxiaWebBundle:Course:coursesBlock', {courses:hotestCourses, view: 'grid'})) }}
        {% else %}
          <div class="empty">还没有发布的课程</div>
        {% endif %}
      </div>

    </div>

{% endblock %}